package com.fly.visit;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fly.core.JsonResult;
import com.fly.visit.service.WebVisitorSevice;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api(tags = "WebApi接口")
@RequestMapping("/api")
@ConditionalOnWebApplication
public class ApiController
{
    @Autowired
    WebVisitorSevice webVisitorSevice;
    
    @ApiOperation("调用后台访问")
    @GetMapping("/call")
    public JsonResult<?> call()
        throws IOException
    {
        webVisitorSevice.backVisit();
        return JsonResult.success("异步请求发送成功");
    }
    
    @ApiOperation("查看articles")
    @GetMapping("/view")
    public JsonResult<?> view()
    {
        return JsonResult.success(webVisitorSevice.getArticles());
    }
}
